public class O63 {
    public int maxProfit(int[] prices) {
        int now = 0,re = 0;
        for (int i = 1; i < prices.length; i++) {
            now+=prices[i]-prices[i-1];
            if (now<0)
                now = 0;
            re = Math.max(re,now);
        }
        return re;
    }
}
